package com.yuexun.beilunpatient.ui.inspect.ui;

import android.text.Html;
import android.view.View;
import android.widget.TextView;

import com.yuexun.beilunpatient.R;
import com.yuexun.beilunpatient.base.BaseKJActivity;
import com.yuexun.beilunpatient.config.AppConfig;
import com.yuexun.beilunpatient.ui.inspect.bean.CheckDetailResp;
import com.yuexun.beilunpatient.ui.inspect.bean.JtRmyyCheckDetailResult;
import com.yuexun.beilunpatient.ui.inspect.model.impl.InspectDetailModel;
import com.yuexun.beilunpatient.ui.inspect.presenter.impl.InspectScanDetailPresenter;
import com.yuexun.beilunpatient.ui.inspect.ui.view.IInspectScanDetailView;

import org.kymjs.kjframe.ui.ViewInject;
import org.kymjs.kjframe.utils.PreferenceHelper;
import org.kymjs.kjframe.utils.SystemTool;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by chenss on 2018/10/11.
 */
public class Act_Inspect_ScanDetail extends BaseKJActivity implements IInspectScanDetailView {
    @Bind(R.id.tv_content)
    TextView tvContent;
    @Bind(R.id.tv_judge)
    TextView tvJudge;
    @Bind(R.id.tv_reportno)
    TextView tvReportno;

    //申请单号
    private String check_no;

    private InspectScanDetailPresenter presenter;

    @Override
    public void setRootView() {
        setContentView(R.layout.act_inspect_dtl);
        ButterKnife.bind(this);
    }

    @Override
    public void initData() {
        super.initData();
        presenter = new InspectScanDetailPresenter(this, new InspectDetailModel());
        check_no = getIntent().getExtras().getString("check_no");


        if (SystemTool.checkNet(aty)) {
            Map<String, String> params = new HashMap<>();
            params.put("queryVal", check_no);
            params.put("queryType", "BGDH");
            params.put("patientName", PreferenceHelper.readString(aty, AppConfig.USER_INFO, AppConfig.USER_NAME));
            presenter.inquireBlrmyyCheckDetail(params);
        } else {
            ViewInject.toast("网络异常，请检查网络是否连接!");
        }
    }

    @OnClick(R.id.iv_back)
    public void onClick(View view) {
        finish();
    }

    @Override
    public void showInspectDetail(ArrayList<JtRmyyCheckDetailResult> list) {
        CheckDetailResp checkDetailResp = list.get(0).getCheckreport();
        if (checkDetailResp.getDiagnostic_performance() != null) {
            tvContent.setText(Html.fromHtml(checkDetailResp.getDiagnostic_performance().replace("\n", "<br>")));
        }
        if (checkDetailResp.getDiagnose_sum() != null) {
            tvJudge.setText(Html.fromHtml(checkDetailResp.getDiagnose_sum().replace("\n", "<br>")));
        }
        tvReportno.setText("单号:" + check_no);
    }
}
